﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Data;
using System.Globalization;

namespace BadHabit.Factory.Converters {

    [ValueConversion(typeof(string), typeof(System.Data.DataRowView))]
    public class SprintBySprintUIdConverter : IValueConverter {


        public static Data.ProjectDataSet ProjectDataSet { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {

            string sprintUId = value.ToString();

            System.Data.DataRow sprint = ProjectDataSet.Sprint.FindBySprintUId(sprintUId);
            if (sprint == null)
                return null;
            return ProjectDataSet.Sprint.DefaultView[ProjectDataSet.Sprint.Rows.IndexOf(sprint)];
            

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            return new NotSupportedException();
        }

    }
}